<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Support\Facades\Auth;

class FollowersController extends Controller
{
    public function followings(User $user)
    {
        $users=$user->followings()->paginate(10);
        return view('users.followings',compact('users'));
    }

    public function followers(User $user)
    {
        $users=$user->followers()->paginate(10);
        return view('users.followers',compact('users'));
    }

    public function follow(User $user)
    {
        Auth::user()->follow($user->id);
        return back();
    }

    public function unfollow(User $user)
    {
        Auth::user()->unfollow($user->id);
        return back();
    }
}
